package com.xwd.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @ClassName LogoutServlet
 * @Description: com.xwd.servlet
 * @Auther: xiwd
 * @Date: 2022/2/13 - 02 - 13 - 0:54
 * @version: 1.0
 */
@WebServlet(
        name = "logoutservlet",
        urlPatterns = {
                "/logoutservlet.do"
        }
)
public class LogoutServlet extends HttpServlet {
    //methods
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doGet(req, resp);
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doPost(req, resp);
        System.out.println("/logoutservlet.do");
        HttpSession session = req.getSession();
        session.invalidate();
    }
}
